package org.dromara.system.service.impl;

import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.dromara.system.domain.bo.SysuserBindingSchoolsBo;
import org.dromara.system.domain.vo.SysuserBindingSchoolsVo;
import org.dromara.system.domain.SysuserBindingSchools;
import org.dromara.system.mapper.SysuserBindingSchoolsMapper;
import org.dromara.system.service.ISysuserBindingSchoolsService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * 用户绑定校区Service业务层处理
 *
 * @author Gjb
 * @date 2025-07-30
 */
@RequiredArgsConstructor
@Service
public class SysuserBindingSchoolsServiceImpl  extends MPJBaseServiceImpl<SysuserBindingSchoolsMapper,SysuserBindingSchools> implements ISysuserBindingSchoolsService {

    private final SysuserBindingSchoolsMapper baseMapper;

    /**
     * 根据教师id 获取所有绑定信息
     * @param tid
     * @return
     */
    @Override
    public List<SysuserBindingSchools> findByUserId(Long tid) {
        MPJLambdaWrapper<SysuserBindingSchools> mpj = new MPJLambdaWrapper<SysuserBindingSchools>();
        mpj.selectAll(SysuserBindingSchools.class)
            .eq(SysuserBindingSchools::getUserId,tid);
        return  baseMapper.selectList(mpj);
    }

    @Override
    public int insert(SysuserBindingSchools bindingSchools) {

        return this.baseMapper.insert(bindingSchools);
    }

    @Override
    public int deleteByUserId(Long tid) {
        MPJLambdaWrapper<SysuserBindingSchools> mpj = new MPJLambdaWrapper<SysuserBindingSchools>();
        mpj.eq(SysuserBindingSchools::getUserId,tid);
        return baseMapper.deleteJoin(mpj);
    }
}
